package com.mice.controller{
	import com.iyimo.core.YEngine;
	import com.iyimo.core.mvc.Controller;
	import com.iyimo.event.Notification;
	import com.iyimo.manager.SpriteManager;
	import com.iyimo.scene.BaseScene;
	import com.iyimo.scene.SceneSwitcher;
	import com.mice.constant.NotifyConst;
	import com.mice.event.GameEvent;
	import com.mice.view.start.StartScene;
	
	import flash.events.Event;
	
	public class StartController extends Controller{
		public static const NAME:String = "StartController";
		
		/**
		 * 开始界面
		 */		
		private var _scene:StartScene;
		
		public function StartController(){
			super();
		}
		
		override public function onRegister():void{
			_scene = new StartScene(SpriteManager.getSprite("startGame"));
			_scene.addEventListener(GameEvent.START_STORY, onStartStory);
			
			listenNotification(NotifyConst.NOTIFY_INIT_COMPLETE, handleNotifyInit);
		}
		
		/**
		 * view中点击开始游戏
		 */		
		private function onStartStory(e:Event):void{
			sendNotification(NotifyConst.NOTIFY_START_STORY);
		}
		
		/**
		 * 初始化完成,显示view
		 */		
		private function handleNotifyInit(noti:Notification):void{
			SceneSwitcher.initalize(_scene, YEngine.instance.layerManager.gameUiLayer);
		}
	}
}